/**
 * Created by luojie on 2018/3/12.
 */
// import '../utils/jQueryRotate.2.2.js'
// import '../utils/jquery.easing.min.js'
import '../css/base.scss'
import '../css/myGifts.scss'
import Layout from '../components/layout'
import pic1 from '../images/prize1.png'
// import pic2 from '../images/prize2.png'
// import pic3 from '../images/prize3.png'
// import pic4 from '../images/prize4.png'
// import pic5 from '../images/prize5.png'

// const openid = "olsJCwx-pWEkoeIn9Hk4dD8J6SnE";
const openid = getCookie("openid");
export default class MyGifts extends React.PureComponent {
    constructor(props) {
        super(props)
        this.state = {
            lists: [
                {
                    text: '关注公众号抽奖机会',
                    num: '+1'
                },
                {
                    text: '每日分享链接抽奖机会',
                    num: '+1'
                },
                {
                    text: '购买会员卡抽奖机会',
                    num: '+2'
                },
                {
                    text: '购买课程抽奖机会',
                    num: '+1'
                }
            ],
            gifts: []
        }
    }
    componentDidMount() {
        this.getList()
    }
    getList() {
        ajax('/twowin/prizeList', {
            openid
        }, 'post').then(res => {
            if(res.status===1){
                this.setState({gifts:res.datas})
            }
        })
    }
    render() {
        const { lists, gifts } = this.state
        return (
            <Layout
                {...this.props}
                active='myGifts'
                noBg={true}
            >
                <div className="top_bg"></div>
                <div className="top_bg_one"></div>
                <div className="top_bg_two"></div>
                <div className="content">
                    <div className="scroll_content">
                        <div className="gift_lists">
                            {
	                            gifts&&gifts.length>0?gifts.map((item, index) => {
                                    return (
                                        item.price ? (
                                            <div className="gift_list" key={index}>
                                                <div className="gift_list_left">
                                                    <div className="gift_list_title">{item.prizeName}</div>
                                                    <div className="gift_list_price">{item.price}</div>
                                                </div>
                                                <div className="gift_list_right">
                                                    <div className="gift_list_num">
                                                        0{index + 1}
                                                    </div>
                                                    <div className="gift_list_pic">
                                                    </div>
                                                </div>
                                            </div>
                                        ) : (
                                                <div className="gift_list" key={index}>
                                                    <div className="gift_list_left">
                                                        <div className="gift_list_title gift_list_title_other">{item.prizeName}</div>
                                                    </div>
                                                    <div className="gift_list_right">
                                                        <div className="gift_list_num">
                                                            0{index + 1}
                                                        </div>
                                                        <div className="gift_list_pic">
                                                            <img src={require(`../images/prize${item.sort}.png`)} alt=""/>
                                                        </div>
                                                    </div>
                                                </div>
                                            )
                                    )
                                }):(
                                    <div className="gift_list">
                                        <div className="gift_list_left">
                                            <div className="no_gift color-fff">还没有奖品哦，请先抽奖</div>
                                        </div>
                                        <div className="gift_list_right">
                                            {/*<div className="gift_list_num">*/}
                                                {/*01*/}
                                            {/*</div>*/}
                                            {/*<div className="gift_list_pic">*/}
                                                {/*<img src={require(`../images/prize1.png`)} alt=""/>*/}
                                            {/*</div>*/}
                                        </div>
                                    </div>
                                )
                            }
                        </div>
                    </div>
                    <div className="news_lists">
                        {
                            lists.map((item, index) => {
                                return (
                                    <div className="news_list" key={index}>
                                        {item.text}<span>{item.num}</span>次
                                    </div>
                                )
                            })
                        }
                    </div>
                    <div className="message">
                        请7天内到豆壳教育广场空港店兑换
                    </div>
                    <div className="bot_bg"></div>
                </div>
            </Layout>
        )
    }
}